import {createStore,applyMiddleware} from 'redux'
import languagereduer from "../Language/languagereduer";
import recommendreducer from "../Recommend/recommendreducer";
import {detailitemSlice} from "../Detailitem/slice";
import {productlistSlice} from "../Search/slice";
import {LoginSlice} from "../LoginIn/slice";
import thunk from 'redux-thunk'
import {combineReducers,configureStore} from '@reduxjs/toolkit'
import {persistStore,persistReducer} from "redux-persist"
import storage from 'redux-persist/lib/storage'
import {BuycarSlice} from "../BuyCar/slice";
import {PaymentSlice} from "../Payment/slice";

const rootReducer=combineReducers({
    language:languagereduer,
    recommend:recommendreducer,
    detailitem:detailitemSlice.reducer,
    productlist:productlistSlice.reducer,
    userlogin:LoginSlice.reducer,
    buycar:BuycarSlice.reducer,
    payment:PaymentSlice.reducer
})
const persisConfig={
    key:"root",
    storage,
    whitelist:["userlogin"]
}
const persistedReducer=persistReducer(persisConfig,rootReducer)
// const store=createStore(rootReducer,applyMiddleware(thunk));
const store=configureStore({reducer:persistedReducer,devTools:true});
const persistor=persistStore(store)
export type RootState=ReturnType<typeof store.getState>
export default {store,persistor};
